package com.huaxin.hxcloud.work;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.huaxin.common.BaseActivity;
import com.huaxin.common.utils.SpacesItemDecoration;
import com.huaxin.hxcloud.R;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * @author lwjing
 * @date 2018/5/23
 * @Desc 力鼎预案管理
 * Copyright HUAXIN DATA. All rights reserved.
 */
public class HxLDPlanManagerActivity extends BaseActivity {

    @BindView(R.id.toolbar)
    Toolbar      mToolbar;
    @BindView(R.id.rl_plan_manager)
    RecyclerView mRl;
    private LDPlanManagerAdapter ldPlanManagerAdapter;
    List<String> planDatas=new ArrayList<>();
    String[] dataArray=new String[]{"调度预案管理","事故预案管理","生产指标告警预案","设备运行告警预案"};

    @Override
    protected void getBundleExtras(Bundle extras) {
        super.getBundleExtras(extras);
    }

    @Override
    protected int getContentViewId() {
        return R.layout.act_ldplan_manager;
    }

    @Override
    protected int getLoadFrameId() {
        return super.getLoadFrameId();
    }

    @Override
    public void initView() {
        setSupportActionBar(mToolbar);
        mToolbar.setTitle("预案管理");
        LinearLayoutManager manager=new LinearLayoutManager(this);
        manager.setOrientation(LinearLayoutManager.VERTICAL);
        mRl.setLayoutManager(manager);
        initDatas();
        ldPlanManagerAdapter=new LDPlanManagerAdapter(R.layout.item_plan_manager,planDatas);
        mRl.setAdapter(ldPlanManagerAdapter);
        mRl.addItemDecoration(new SpacesItemDecoration(30));

        ldPlanManagerAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                HxLDPlanContentActivity.start(HxLDPlanManagerActivity.this,position+1,planDatas.get(position));
            }
        });

    }

    /**
     * 数据初始化
     */
    private void initDatas() {
        for (int i=0;i< dataArray.length;i++){
            planDatas.add(dataArray[i]);
        }
    }

    @Override
    protected void requestData() {
        super.requestData();
    }

    class LDPlanManagerAdapter extends BaseQuickAdapter<String,BaseViewHolder>{


        public LDPlanManagerAdapter(int layoutResId, @Nullable List<String> data) {
            super(layoutResId, data);
        }

        @Override
        protected void convert(BaseViewHolder helper, String item) {
            TextView tv_plan_colunm=helper.getView(R.id.tv_plan_colunm);
            tv_plan_colunm.setText(item);
        }
    }

}
